﻿using UnityEngine;
using System.Collections;
using ALPackage;
using System;

namespace HYOK
{
    /************************
    * 尝试网络重联（菊花）
    **/
    public class NPGGUIAddSceneReconnecting : _ABasicAdditionUIScene_NoChild
    {
        private static NPGGUIAddSceneReconnecting _g_instance = new NPGGUIAddSceneReconnecting();
        public static NPGGUIAddSceneReconnecting instance
        {
            get
            {
                if (null == _g_instance)
                    _g_instance = new NPGGUIAddSceneReconnecting();

                return _g_instance;
            }
        }

        private NPPGUIWndInstanceTransparentBk _m_twTransparentBkWnd;
        private long _m_lSerialize;

        public NPGGUIAddSceneReconnecting()
            : base()
        {
            _m_lSerialize = ALSerializeOpMgr.next();
        }


        protected override void _onEnterScene()
        {
            //开启背景窗口加载
            if (null != _m_twTransparentBkWnd)
            {
                _m_twTransparentBkWnd.showWnd();
                _afterTransBkAction();
            }
            else
            {
                _m_lSerialize = ALSerializeOpMgr.next();
                long serialize = _m_lSerialize;
                _m_twTransparentBkWnd = NPPGUIWndInstanceTransparentBk.showTransparentBk(null, () =>
                {
                    if(serialize != _m_lSerialize)
                        return;
                    
                    _afterTransBkAction();
                });
            }
        }

        /// <summary>
        /// 透明背景处理后的实际窗口显示处理
        /// </summary>
        protected void _afterTransBkAction()
        {
            //开启窗口加载
            //NPPGUIWndReconnecting.instance.load(_onLoadingInited);
        }

        protected override void _dealQuitScene()
        {
            _m_lSerialize = ALSerializeOpMgr.next();

            //卸载窗口
            NPUIInstanceTransparentBkController.instance.hideTransparentBk(_m_twTransparentBkWnd);
            _m_twTransparentBkWnd = null;

            //NPPGUIWndReconnecting.instance.discard();
        }

        protected override void _onSceneInited()
        {
        }

        protected void _onLoadingInited()
        {
            //显示窗口
            //NPPGUIWndReconnecting.instance.showWnd();
        }


    }
}
